import request from '@/utils/request'

// 新增物品
export const addItemService = (itemAddDTO) => {
  return request.post('/admin/item/add', itemAddDTO)
}

// 物品分页查询
export const itemPageQueryService = (itemPageQueryDTO) => {
  return request.get('/admin/item/page', { params: itemPageQueryDTO })
}

// 启用/禁用物品状态
export const updateItemStatusService = (status, id) => {
  return request.post(`/admin/item/status/${status}`, null, { params: { id } })
}

// 根据物品id查询物品信息
export const getItemByIdService = (id) => {
  return request.get(`/admin/item/${id}`)
}

// 修改物品信息
export const updateItemService = (itemUpdateDTO) => {
  return request.put('/admin/item', itemUpdateDTO)
}

// 删除物品
export const deleteItemService = (id) => {
  return request.delete(`/admin/item/${id}`)
}

// 新增物品类别
export const addItemCategoryService = (itemCategoryName) => {
  return request.post('/admin/item/category/add', null, { params: { itemCategoryName } })
}

// 物品类别分页查询
export const itemCategoryPageQueryService = (itemCategoryPageQueryDTO) => {
  return request.get('/admin/item/category/page', { params: itemCategoryPageQueryDTO })
}

// 启用/禁用物品类别状态
export const updateItemCategoryStatusService = (status, id) => {
  return request.post(`/admin/item/category/status/${status}`, null, { params: { id } })
}

// 根据物品类别id查询物品类别信息
export const getItemCategoryByIdService = (id) => {
  return request.get(`/admin/item/category/${id}`)
}

// 修改物品类别信息
export const updateItemCategoryService = (itemCategoryUpdateDTO) => {
  return request.put('/admin/item/category', itemCategoryUpdateDTO)
}

// 删除物品类别
export const deleteItemCategoryService = (id) => {
  return request.delete(`/admin/item/category/${id}`)
}

// 查询所有启用的物品类别
export const listItemCategoryService = () => {
  return request.get('/admin/item/category/list')
}

// 物品入库
export const addItemStockService = (itemStockUpdateDTOList) => {
  return request.post('/admin/item/stock/add', itemStockUpdateDTOList)
}

// 物品出库
export const reduceItemStockService = (itemStockUpdateDTOList) => {
  return request.post('/admin/item/stock/reduce', itemStockUpdateDTOList)
}

// 物品库存记录分页查询
export const itemStockRecordPageQueryService = (itemStockRecordPageQueryDTO) => {
  return request.get('/admin/item/stock/page', { params: itemStockRecordPageQueryDTO })
}
